//
//  NvTextViewWithCancelButton.m
//  NvSellerShow
//
//  Created by dx on 17/2/20.
//  Copyright © 2017年 Meicam. All rights reserved.
//

#import "NvTextViewWithCancelButton.h"

@implementation NvTextViewWithCancelButton
{
    UIButton *doneBtn;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self keyboardview];
    }
    return self;
}

- (instancetype)initWithCoder:(NSCoder *)coder
{
    if (self = [super initWithCoder:coder])
    {
        [self keyboardview];
    }
    return self;
}

-(void) keyboardview
{
    doneBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    CGRect exitBtFrame = CGRectMake(Screen_WIDTH-44, 0, 44.0f, 44.0f);
    doneBtn.frame = exitBtFrame;
    NSString *path = [[NSBundle mainBundle] pathForResource:@"NvSellerResource" ofType:@"bundle"];
    NSBundle *myBundle = [NSBundle bundleWithPath:path];
    [doneBtn setBackgroundImage:[UIImage imageWithContentsOfFile:[myBundle pathForResource:@"cam_cancel" ofType:@"png"]] forState:UIControlStateNormal];
    [doneBtn addTarget:self action:@selector(CancelBackKeyboard) forControlEvents:UIControlEventTouchDown];
    

    UIView *inputview = [[UIView alloc]init];
    inputview.frame = CGRectMake(0, 0, Screen_WIDTH, 44);
    [inputview addSubview:doneBtn];
    [self setInputAccessoryView:inputview];
}


//收回键盘
- (void)CancelBackKeyboard
{
    [self resignFirstResponder];
}

@end
